"""
pirates

A module for the various types of pirates that inhabit ships, ports,
forts, and islands.
"""

#TODO: Write classes for the various special figs
import dice

# BlindEyes
(BE_NONE,
 BE_LEFTPATCH,
 BE_LEFTGLASS,
 BE_RIGHTPATCH,
 BE_RIGHTGLASS) = range(5)

# PegLegs
(PL_NONE,
 PL_LEFT,
 PL_RIGHT,
 PL_BOTH) = range(4)

# HookHands
(HH_NONE,
 HH_LEFT,
 HH_RIGHT) = range(3)

# Weapons for hands
(WE_PISTOL,
 WE_RIFLE,
 WE_MUSKET,
 WE_CUTLASS,
 WE_KNIFE,
 WE_OAR,
 WE_GRENADE,
 WE_AXE,
 WE_SHOVEL) = range(9)

# Roles
(RO_ADMIRAL,
 RO_CAPTAIN,
 RO_QUARTERMASTER,
 RO_FIRSTMATE,
 RO_BOATSWAIN,
 RO_CABINBOY,
 RO_CARPENTER,
 RO_GUNNER,
 RO_PILOT,
 RO_NAVIGATOR,
 RO_STRIKER,
 RO_SURGEON,
 RO_COOK,
 RO_SECONDMATE,
 RO_HAND) = range(15)
 
class Person(object):
    # Weapons, tools, etc.
    leftItem = None
    rightItem = None
    
    # Various prosthetics
    pegLeg = PL_NONE
    hookHand = HH_NONE
    blindEye = BE_NONE
    
    # Decoration
    cape = None
    hat = None
    
    # Skills
    skills = None
    
    # Personal Inventory
    equipment = None
        
    def __init__(self, leftItem=None, rightItem=None,
                       pegLeg=PL_NONE, hookHand = HH_NONE, blindEye=BE_NONE):
        
        self.skills = {}
        self.leftItem = leftItem
        self.rightItem = rightItem
        self.pegLeg = pegLeg
        self.hookHand = hookHand
        self.blindEye = blindEye
    
    def move(self, direction, distance):
        pass
    
    def attack(self, target=None):
        pass


class StowAway(Person):
    pass


class Slave(Person):
    pass


class Homunculus(Person):
    # Pet parrot, monkey, cat, dog, etc.
    # Almost definitely not a person,
    #   but mimics one.
    pass


class Pirate(Person):
    # Also includes pirate captains,
    # pirate admiralty, etc.
    boss = None
    role = RO_HAND
    
    homunculus = None
    
    def __init__(self, captain=None, leftItem=WE_PISTOL, rightItem=WE_CUTLASS):
        Person.__init__(self, leftItem, rightItem)
        self.boss = captain
        self.leftItem = leftItem
        self.rightItem = rightItem

def createRandomPirate(captain=None):
    # Pirates who have standard skills
    
    left = WE_PISTOL
    right = WE_CUTLASS
    
    # Hook hand
    hh = dice.dice1d6.roll()
    if hh == 1:
        hh = HH_RIGHT
        right = WE_NONE
    elif hh == 2:
        hh = HH_LEFT
        left = WE_NONE
        right = WE_PISTOL
    else:
        hh = HE_NONE
    
    # Peg leg
    pl = dice.dice1d6.roll()
    if pl < 4:
        pl = 4 - pl
    else:
        pl = PL_NONE
    
    # Blind eye
    be = dice.dice1d6.roll()
    if be == 1:
        be = dice.dice1d4.roll()
    else:
        be = BE_NONE
    
    pirate = Pirate(captain, left, right)
    pirate.blindEye = be
    pirate.pegLeg = pl
    pirate.hookHand = hh
    return pirate


def createRandomSpecialPirate():
    # Pirates who start with special skills
    pass



class MilitaryMan(Person):
    # Police officer, Royal Navy, Privateer, etc.
    # Enforcer of laws.
    pass


class CorporateMan(Person):
    # Crew/Captain for East India, Royal African, etc.
    # State-Sanctioned Trader.
    pass


class Statesman(Person):
    # eg. Major-General in Penzance
    #     Governor Swann in PotC
    pass


class MainlandTrader(Person):
    # Staffs a State-Sanctioned Trading Port
    pass


class PirateTrader(Person):
    # Staffs a Pirate (Free) Trading Port
    pass


class IslandNative(Person):
    pass


